<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>

<configuration scan="true" scanPeriod="3600 seconds" debug="false">

	<jmxConfigurator/>
	 
    <property resource="properties/application.properties" />
    <property name="appName" value="${r"${app.name}"}"/>
    <property name="logLevel" value="log.level"/>
    <property name="logDir" value="${r"${log.directory}"}"/>
    <property name="pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n"/>
    
    <!-- ConsoleAppender 控制台输出日志 -->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>${r"${pattern}"}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>
    
    <!-- ERROR级别日志 -->
    <appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>ERROR</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${r"${logDir}"}/${r"${appName}"}-error-%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${r"${pattern}"}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <!-- INFO级别日志 -->
    <appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>INFO</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${r"${logDir}"}/${r"${appName}"}-info-%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${r"${pattern}"}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>
    
    <!-- INFO级别日志 -->
    <appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
        <filter class="ch.qos.logback.classic.filter.LevelFilter">
            <level>DEBUG</level>
            <onMatch>ACCEPT</onMatch>
            <onMismatch>DENY</onMismatch>
        </filter>
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <FileNamePattern>${r"${logDir}"}/${r"${appName}"}-debug-%d{yyyy-MM-dd}.log</FileNamePattern>
            <MaxHistory>30</MaxHistory>
        </rollingPolicy>
        <encoder>
            <pattern>${r"${pattern}"}</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>
    
    <!-- 日志只输出error -->
    <logger name="dubbo.accesslog" level="ERROR" />
    <logger name="org.springframework" level="ERROR"/>
    <logger name="org.apache.commons.beanutils" level="ERROR"/>
    <logger name="dubbo.accesslog" level="ERROR" />
    <logger name="org.springframework" level="ERROR"/>
    <logger name="org.quartz" level="ERROR"/>
    <logger name="org.mybatis.spring" level="ERROR"/>
    <logger name="com.alibaba.druid" level="ERROR"/>
    <logger name="org.apache.zookeeper" level="ERROR" />
    <logger name="com.alibaba.dubbo" level="ERROR"><appender-ref ref="dubboRolling"/></logger>
    
    <root>
        <level value="${r"${logLevel}"}"/>
        <appender-ref ref="console"/>
        <appender-ref ref="ERROR"/>
        <appender-ref ref="INFO"/>
        <appender-ref ref="DEBUG"/>
    </root>
    
</configuration>